$(function () {
    //审核事件
    $(document).on('click', '.checkAgent', function () {
        var formData = {};
        var flag = true;
        $('.agentForm').find('input').each(function (index,element) {
            if(element.name !='parentTeamId' && element.value ==''){
                $.alert(element.placeholder);
                flag = false;
                return false;
            }else if(element.value !=''){
                formData[element.name] = element.value;
            }
        });
        if(flag == false){
            return;
        }
        // 异步提交数据请求
        $.ajax({
            type: "POST",
            url: "/userTeam/userteam/checkAgent",
            contentType: "application/json",
            data: JSON.stringify(formData),
            success: function (r) {
                if (r.code === 0) {
                    $.alert(r.msg);
                    $.alert(r.msg, function () {
                        window.location.reload()
                    });
                } else {
                    $.alert(r.msg);
                }
            }
        });
    });
})